<template>
  <!-- 分类模态框 -->
  <el-dialog
    :title="titleMap[dialogStatus]"
    :visible.sync="dialogVisible"
    width="40%"
    @close="handleDialogClose"
  >
    <el-form ref="dataForm" :model="form" :rules="rules" label-width="100px">
      <el-form-item :label="tempDesc.parentName" prop="parentName">
        <el-input
          v-model="currentCheckNodeData.name"
          disabled="disabled"
        ></el-input>
      </el-form-item>
      <el-form-item :label="tempDesc.preId" prop="preId">
        <el-input v-model="form.preId"></el-input>
      </el-form-item>
      <el-form-item :label="tempDesc.name" prop="name">
        <el-input v-model="form.name"></el-input>
      </el-form-item>
      <el-form-item :label="tempDesc.description" prop="description">
        <el-input v-model="form.description"></el-input>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="dialogVisible = false">取消</el-button>
      <el-button type="primary" @click="submitForm">提交</el-button>
    </span>
  </el-dialog>
</template>

<script>
  // 常量title
  const tempDesc = {
    preId: '分类编号',
    parantName: '父节点',
    name: '分类名称',
    description: '描述',
  }

  export default {
    name: 'ClassifyDialog',
    props: {
      /*      // 带有默认值的数字
      dialogVisible: {
        type: Number,
        default: 100,
      },*/
    },
    data() {
      return {
        listLoading: true,
        total: 0,
        listQuery: {
          page: 1,
          limit: 10,
          userName: undefined,
        },
        dialogVisible: false,
        form: {
          id: undefined, //主键ID
        },
        dialogStatus: '',
        titleMap: {
          update: '编辑',
          create: '创建',
        },
        rules: {
          name: [{ required: true, message: '请输入账号', trigger: 'blur' }],
          pwd: [
            { pattern: /^(\w){6,16}$/, message: '请设置6-16位字母、数字组合' },
          ],
        },
      }
    },
    created() {},
    methods: {
      getList() {
        this.listLoading = true
        // getSysUserPage(this.listQuery).then(response => {
        //   this.list = response.data.records
        //   this.total = response.data.total
        //   this.listLoading = false
        // })
      },
      handleCreate() {
        this.resetForm()
        this.dialogStatus = 'create'
        this.dialogVisible = true
      },
      handleUpdate(row) {
        this.form = Object.assign({}, row)
        this.dialogStatus = 'update'
        this.dialogVisible = true
      },
      handleDelete(row) {
        let id = row.id
        deleteSysUser(id).then((response) => {
          if (response.code == 200) {
            this.getList()
            this.submitOk(response.message)
          } else {
            this.submitFail(response.message)
          }
        })
      },
    },
  }
</script>
<style scoped></style>
